def output(db):
    columns=db.table_info("STD")
    print(columns)
    eles=columns[2:]
    eles=[ele[:-1] for ele in eles]
    print(eles)
    r=[]
    for one in eles:
    	r.append("""{
                "name": "%s",
                "type": "item",
                "alias": "%s",
                "titleName": "%s"
            }""" % (one,one,one))
    eles_out=",".join(r)+","
    out="""{
        "col":
        [
            {
                "dict":
                [{
                        "alias": "二级方法",
                        "delimiter": "&",
                        "identifier": "ejff"
                    },
                    {
                        "alias": "二级分析技术",
                        "delimiter": "&",
                        "identifier": "ejfxjs"
                    },
                    {
                        "alias": "方法编号",
                        "delimiter": "&",
                        "identifier": "ffbh"
                    },
                    {
                        "alias": "试验员",
                        "delimiter": "&",
                        "identifier": "syy"
                    },
                    {
                        "alias": "一审人员",
                        "delimiter": "&",
                        "identifier": "ysry"
                    },
                    {
                        "alias": "一审时间",
                        "delimiter": "&",
                        "identifier": "yssj"
                    },
                    {
                        "alias": "仪器编号",
                        "delimiter": "&",
                        "identifier": "yqbh"
                    },
                    {
                        "alias": "实验员签名",
                        "delimiter": "&",
                        "identifier": "syyqm"
                    },
                    {
                        "alias": "浓度",
                        "delimiter": "&",
                        "identifier": "nd"
                    },
                    {
                        "alias": "波长",
                        "delimiter": "&",
                        "identifier": "bc"
                    },
                    {
                        "alias": "天平编号",
                        "delimiter": "&",
                        "identifier": "tpbh"
                    },
                    {
                        "alias": "内标元素",
                        "delimiter": "&",
                        "identifier": "nbys"
                    }
                ],
                "isPK": "true",
                "name": "样品编号",
                "type": "sample",
                "alias": "SampleCode",
                "ifHandle": "false",
                "exeScript": "",
                "preHandle": "false",
                "titleName": "id",
                "rowFilterScript": "v.length()>=1"
            },
            %s
        ],
        "name": "spec",
        "start":
        {
            "dataMode": "fixed",
            "startRow": "1",
            "titleRow": "0",
            "findPosScript": ""
        },
        "charSet": "GBK",
        "parserMode": "name",
        "parserSource": "file-excel"
    }""" % eles_out
    f=open("spec.json","w",encoding="utf-8")
    f.write(out)
    f.close()
if __name__=="__main__":
    import mydb
    db=mydb.MyDb()
    output(db)